package com.andong.controller;

import com.andong.annotations.AccessControl;
import com.andong.domain.entity.CoachScore;
import com.andong.domain.pojo.Result;
import com.andong.service.CoachScoreService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static com.andong.utils.SystemConstant.*;

/**
 * 教练评分表(CoachScore)表控制层
 *
 * @author makejava
 * @since 2024-01-13 14:38:01
 */
@RestController
@RequestMapping("/coachScore")
public class CoachScoreController {
    /**
     * 服务对象
     */
    @Resource
    private CoachScoreService coachScoreService;

    @GetMapping("/{id}")
    @AccessControl(roles = {STUDENT, COACH, ADMIN, SUPER_ADMIN}, permission = "教练管理")
    public Result getAverage(@PathVariable Long id) {
        return coachScoreService.getAverage(id);
    }

    @PostMapping()
    @AccessControl(roles = STUDENT)
    public Result saveOrUpdate(@RequestBody CoachScore coachScore) {
        return coachScoreService.saveOrModify(coachScore);
    }

    @GetMapping()
    @AccessControl(roles = STUDENT)
    public Result getScoreByStudentId(Long studentId, Long coachId) {
        return coachScoreService.getScoreByStudentId(studentId, coachId);
    }

}

